import { Component, ViewChild } from '@angular/core';
import { Nav, Platform, NavController} from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

import { TabsPage } from '../pages/tabs/tabs';
import { LoginPage } from '../pages/login/login';
import { SidebarPage } from '../pages/sidebar/sidebar';
import { HomePage } from '../pages/home/home';
import { UsrInfoProvider } from '../providers/usr-info/usr-info';
@Component({
  templateUrl: 'app.html'
})
export class Alphair {

  @ViewChild(Nav) nav: Nav;

  rootPage:any = LoginPage;

  pages: Array<{title: string, component: any}>;

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen,private usrInfoProvider : UsrInfoProvider) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      //判断是否已经登陆过
      if(this.usrInfoProvider.read("usr_info")!=null)
      {
        //this.nav.setRoot(TabsPage);
        console.log(this.usrInfoProvider.read("usr_info"));
      }
      else
      {
        console.log("---用户未登录");
      }
      statusBar.styleDefault();
      splashScreen.hide();
    });
    // used for an example of ngFor and navigation
    this.pages = [
      { title: 'Home', component: HomePage },
      { title: 'List', component: SidebarPage }
    ];
  }
  openPage(page) {
    // Reset the content nav to have just this page
    // we wouldn't want the back button to show in this scenario
    this.nav.setRoot(page.component);
  }
}
